import Vue from 'vue'
import VueRouter from 'vue-router'
// component: () => import('../views/Stores/BasicInfo/BasicInfo.vue')

Vue.use(VueRouter)

// 解决重复点菜单报错（该问题不影响使用）
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
}

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    component: () => import('../views/Login/Login.vue')
  },

  // 基本资料
  {
    // 厂商建档
    path: '/basic_info/vendor_doc',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/BasicInfo/VendorDoc/VendorDoc.vue')
  },
  {
    // 品牌建档
    path: '/basic_info/brand_doc',
    component: () => import('../views/BasicInfo/BrandDoc/BrandDoc.vue')
  },
  {
    // 颜色与季度别名建档
    path: '/basic_info/colorSeason_doc',
    component: () =>
      import('../views/BasicInfo/ColorSeasonDoc/ColorSeasonDoc.vue')
  },
  {
    // 尺码建档
    path: '/basic_info/size_doc',
    component: () => import('../views/BasicInfo/SizeDoc/SizeDoc.vue')
  },
  {
    // 品名建档
    path: '/basic_info/product_name_doc',
    component: () =>
      import('../views/BasicInfo/ProductNameDoc/ProductNameDoc.vue')
  },
  {
    // 附件建档
    path: '/basic_info/attachment_doc',
    component: () =>
      import('../views/BasicInfo/AttachmentDoc/AttachmentDoc.vue')
  },
  {
    // 成分建档
    path: '/basic_info/composition_doc',
    component: () =>
      import('../views/BasicInfo/CompositionDoc/CompositionDoc.vue')
  },
  {
    // 客户建档
    path: '/basic_info/client_doc',
    component: () => import('../views/BasicInfo/ClientDoc/ClientDoc.vue')
  },
  {
    // 仓库建档
    path: '/basic_info/warehouse_doc',
    component: () => import('../views/BasicInfo/WarehouseDoc/WarehouseDoc.vue')
  },
  {
    // 货号建档
    path: '/basic_info/art_no',
    component: () => import('../views/BasicInfo/ArtNo/ArtNo.vue')
  },
  {
    // 成本建档
    path: '/basic_info/cost_doc',
    component: () => import('../views/BasicInfo/CostDoc/CostDoc.vue')
  },
  {
    // 职员建档
    path: '/basic_info/clerk_doc',
    component: () => import('../views/BasicInfo/ClerkDoc/ClerkDoc.vue')
  },
  {
    // 吊牌洗标打印
    path: '/basic_info/tags1',
    component: () => import('../views/BasicInfo/Tags/Tags1.vue')
  },
  {
    // 吊牌洗标打印2
    path: '/basic_info/tags2',
    component: () => import('../views/BasicInfo/Tags/Tags2.vue')
  },
  {
    // 科目明细建档
    path: '/basic_info/subject_doc',
    component: () => import('../views/BasicInfo/SubjectDoc/SubjectDoc.vue')
  },
  {
    // 现金银行流水账
    path: '/basic_info/general_journal',
    component: () =>
      import('../views/BasicInfo/GeneralJournal/GeneralJournal.vue'),
    children: [
      {
        path: '/basic_info/general_journal',
        redirect: '/basic_info/general_journal/detail'
      },
      {
        // 明细
        path: '/basic_info/general_journal/detail',
        component: () =>
          import('../views/BasicInfo/GeneralJournal/childComps/gjDetail.vue')
      },
      {
        // 汇总
        path: '/basic_info/general_journal/summary',
        component: () =>
          import('../views/BasicInfo/GeneralJournal/childComps/gjSummary.vue')
      },
      {
        // 列图
        path: '/basic_info/general_journal/picture',
        component: () =>
          import('../views/BasicInfo/GeneralJournal/childComps/gjPicture.vue')
      }
    ]
  },
  {
    // 部门建档
    path: '/basic_info/department_doc',
    component: () =>
      import('../views/BasicInfo/DepartmentDoc/DepartmentDoc.vue')
  },
  {
    // 季度建档
    path: '/basic_info/quarter_doc',
    component: () => import('../views/BasicInfo/K_QuarterDoc/K_QuarterDoc.vue')
  },
  // 进货管理
  {
    // 厂商进货
    path: '/input/vendor_stock_mn',
    component: () => import('../views/Input/VendorStock/VendorStock.vue')
  },
  {
    // 厂商退货
    path: '/input/vendor_return_mn',
    component: () => import('../views/Input/VendorReturn/VendorReturn.vue')
  },
  {
    // 厂商销售
    path: '/input/vendor_sales',
    component: () => import('../views/Input/VendorSales/VendorSales.vue')
  },
  {
    // 厂商进货查询
    path: '/input/vendor_stock_query',
    component: () =>
      import('../views/Input/VendorStockQuery/VendorStockQuery.vue')
  },
  {
    // 厂商退货查询
    path: '/input/vendor_return_query',
    component: () =>
      import('../views/Input/VendorReturnQuery/VendorReturnQuery.vue')
  },
  {
    // 厂商进销比
    path: '/input/vendor_purchase_sales_ratio',
    component: () =>
      import(
        '../views/Input/VendorPurchaseSalesRatio/VendorPurchaseSalesRatio.vue'
      )
  },
  {
    // 厂商品牌销售查询
    path: '/input/vendor_brand_sales',
    component: () =>
      import('../views/Input/VendorBrandSales/VendorBrandSales.vue')
  },
  {
    // 厂商进退付款
    path: '/input/vendor_payment_detail',
    component: () =>
      import('../views/Input/K_VendorPaymentDetail/K_VendorPaymentDetail.vue')
  },

  //开通服务
  {
    path: '/peningservice/opening_service',
    component: () => import('../views/OpeningService/OpeningService.vue')
  },

  // 客户管理
  {
    // 客户进货
    path: '/customer/client_stock_mn',
    component: () => import('../views/Customer/ClientStock/ClientStock.vue')
  },
  {
    // 客户退货
    path: '/customer/client_return_mn',
    component: () => import('../views/Customer/ClientReturn/ClientReturn.vue')
  },
  {
    // 客户销货
    path: '/customer/client_sales_mn',
    component: () => import('../views/Customer/ClientSales/ClientSales.vue')
  },
  {
    // 客户盘点销退货
    path: '/customer/client_sales_return',
    component: () =>
      import('../views/Customer/ClientSalesReturn/ClientSalesReturn.vue')
  },
  {
    // 客户进货查询
    path: '/customer/client_stock_query',
    component: () =>
      import('../views/Customer/ClientStockQuery/ClientStockQuery.vue')
  },
  {
    // 客户退货查询
    path: '/customer/client_return_query',
    component: () =>
      import('../views/Customer/ClientReturnQuery/ClientReturnQuery.vue')
  },
  {
    // 客户销货查询
    path: '/customer/client_sales_query',
    component: () =>
      import('../views/Customer/ClientSalesQuery/ClientSalesQuery.vue')
  },
  {
    // 客户未出款查询
    path: '/customer/client_unpaid_query',
    component: () =>
      import('../views/Customer/ClientUnpaidQuery/ClientUnpaidQuery.vue')
  },
  {
    // 综合查询
    path: '/customer/client_integrated_query',
    component: () =>
      import(
        '../views/Customer/ClientIntegratedQuery/ClientIntegratedQuery.vue'
      )
  },
  {
    // 客户销售分析图表
    path: '/customer/client_sales_analysis',
    component: () =>
      import('../views/Customer/ClientSalesAnalysis/ClientSalesAnalysis.vue')
  },
  // 新增(wo)
  {
    // 客户辅料明细
    path: '/customer/client_accessories_detail',
    component: () =>
      import('../views/Accounting/Client_Fu_Liao_detail/ClientFuLiaoDetail.vue')
  },
  {
    // 客户配货
    path: '/customer/client_distribution',
    component: () =>
      import('../views/Customer/ClientDistribution/ClientDistribution.vue')
  },
  {
    // 客户返修
    path: '/customer/client_repair',
    component: () => import('../views/Customer/ClientRepair/ClientRepair.vue')
  },
  {
    // 客户调货
    path: '/customer/client_transfer',
    component: () =>
      import('../views/Customer/ClientTransfer/ClientTransfer.vue')
  },
  {
    // 客户销售未补
    path: '/customer/client_no_replenishment',
    component: () =>
      import(
        '../views/Customer/ClientNoReplenishment/ClientNoReplenishment.vue'
      )
  },

  // 库存管理
  {
    // 仓库库存表
    path: '/inventory/warehouse_inventory',
    component: () =>
      import('../views/Inventory/WarehouseInventory/WarehouseInventory.vue')
  },
  // 新建
  // 合并的库存表
  {
    // 这个路径必须要和路由路径一样才行
    path: '/inventory/menu_settings',
    component: () =>
      import('../views/Inventory/InventoryQuery/InventoryQuery.vue')
  },
  {
    // 客户库存表
    path: '/inventory/client_inventory',
    component: () =>
      import('../views/Inventory/ClientInventory/ClientInventory.vue')
  },
  {
    // 货品畅销排行
    path: '/inventory/best_selling',
    component: () => import('../views/Inventory/BestSelling/BestSelling.vue')
  },
  {
    // 仓库盘差
    path: '/inventory/warehouse_difference_wd',
    component: () =>
      import('../views/Inventory/WarehouseDifference/WarehouseDifference.vue')
  },
  {
    // 仓库调拨
    path: '/inventory/warehouse_transfers_wd',
    component: () =>
      import('../views/Inventory/WarehouseTransfers/WarehouseTransfers.vue')
  },
  {
    // 货品进销存统计
    path: '/inventory/sales_stock_statistics',
    component: () =>
      import('../views/Inventory/SalesStockStatistics/SalesStockStatistics.vue')
  },
  {
    // 进销存综合查询
    path: '/inventory/integrated_query_i',
    component: () =>
      import('../views/Inventory/IntegratedQuery/IntegratedQuery.vue')
  },
  {
    // 仓库调拨查询
    path: '/inventory/warehouse_transfers_query',
    component: () =>
      import(
        '../views/Inventory/WarehouseTransfersQuery/WarehouseTransfersQuery.vue'
      )
  },
  {
    // RFID电子标签跟踪查询
    path: '/inventory/rfid_track_query',
    component: () =>
      import('../views/Inventory/RFIDTrackQuery/RFIDTrackQuery.vue')
  },
  {
    // 仓库盘差明细查询
    path: '/inventory/warehouse_difference_query',
    component: () =>
      import(
        '../views/Inventory/WarehouseDifferenceQuery/WarehouseDifferenceQuery.vue'
      )
  },

  {
    // 仓库盘点
    path: '/inventory/warehouse_take_stock_i',
    component: () =>
      import('../views/Inventory/WarehouseTakeStock/WarehouseTakeStock.vue')
  },
  {
    // 仓库盘点查询
    path: '/inventory/warehouse_take_stock_query',
    component: () =>
      import(
        '../views/Inventory/WarehouseTakeStockQuery/WarehouseTakeStockQuery.vue'
      )
  },
  {
    // 款号明细记录
    path: '/inventory/style_detail',
    component: () => import('../views/Inventory/StyleDetail/StyleDetail.vue')
  },

  // 账务管理
  {
    // 客户对账汇总
    path: '/accounting/client_account_check',
    component: () =>
      import('../views/Accounting/ClientAccountCheck/ClientAccountCheck.vue')
  },
  {
    // 客户寄卖对账单
    path: '/accounting/client_sell_bill',
    component: () =>
      import('../views/Accounting/ClientSellBill/ClientSellBill.vue')
  },
  {
    // 客户收款结账
    path: '/accounting/client_collection',
    component: () =>
      import('../views/Accounting/ClientCollection/ClientCollection.vue')
  },
  {
    // 客户对账明细与汇总表
    path: '/accounting/client_account_detail',
    component: () =>
      import('../views/Accounting/ClientAccountDetail/ClientAccountDetail.vue')
  },
  {
    // 厂商对账单
    path: '/accounting/vendor_pay',
    component: () => import('../views/Accounting/VendorPay/VendorPay.vue')
  },
  {
    // 月结操作
    path: '/accounting/monthly_statement',
    component: () =>
      import('../views/Accounting/MonthlyStatement/MonthlyStatement.vue')
  },
  {
    // 客户其他应收查询
    path: '/accounting/client_receivable',
    component: () =>
      import('../views/Accounting/ClientReceivable/ClientReceivable.vue')
  },
  {
    // 客户其他应收
    path: '/accounting/client_receive',
    component: () =>
      import('../views/Accounting/ClientReceive/ClientReceive.vue')
  },
  {
    // 厂商对账
    path: '/accounting/vendor_bill',
    component: () => import('../views/Accounting/VendorBill/VendorBill.vue')
  },
  // 客进退利润
  {
    path: '/accounting/businessman_profit',
    component: () =>
      import('../views/Accounting/K_CustomerProfit/K_CustomerProfit.vue')
  },
  // 新增厂商付款结账
  {
    path: '/accounting/manufacturerPayment_checkout',
    component: () =>
      import('../views/Accounting/ManufacturerPayment/ManufacturerPayment.vue')
  },
  // 订单管理
  {
    // 客户订货
    path: '/order/client_order_goods_vo',
    component: () =>
      import('../views/Order/ClientOrderGoods/ClientOrderGoods.vue')
  },
  {
    // 客户订货查询
    path: '/order/client_order_goods_query',
    component: () =>
      import('../views/Order/ClientOrderGoodsQuery/ClientOrderGoodsQuery.vue')
  },
  {
    // 客户订货合计
    path: '/order/client_order_goods_total',
    component: () =>
      import('../views/Order/ClientOrderGoodsTotal/ClientOrderGoodsTotal.vue')
  },
  {
    // 客户订货未交量查询
    path: '/order/client_order_goods_undelivered',
    component: () =>
      import(
        '../views/Order/ClientOrderGoodsUndelivered/ClientOrderGoodsUndelivered.vue'
      )
  },
  {
    // 厂商订货
    path: '/order/vendor_order_goods_vo',
    component: () =>
      import('../views/Order/VendorOrderGoods/VendorOrderGoods.vue')
  },
  {
    // 厂商订货查询
    path: '/order/vendor_order_goods_query',
    component: () =>
      import('../views/Order/VendorOrderGoodsQuery/VendorOrderGoodsQuery.vue')
  },
  {
    // 厂商订货合计
    path: '/order/vendor_order_goods_total',
    component: () =>
      import('../views/Order/VendorOrderGoodsTotal/VendorOrderGoodsTotal.vue')
  },
  {
    // 订货明细
    path: '/order/order_goods_detail',
    component: () =>
      import('../views/Order/OrderGoodsDetail/OrderGoodsDetail.vue')
  },

  // 直营店管理
  {
    // 店铺销售
    path: '/stores/store_sales_s',
    // 旧版组件
    // component: () => import('../views/Stores/StoreSales/StoreSales.vue')
    // 新版组件
    component: () => import('../views/Stores/StoreSalesNew/StoreSales.vue')
  },
  {
    // 店铺盘点
    path: '/stores/store_take_stock_s',
    component: () => import('../views/Stores/StoreInventory/StoreInventory.vue')
  },
  {
    // 店铺退货
    path: '/stores/store_return_s',
    component: () => import('../views/Stores/StoreReturn/StoreReturn.vue')
  },
  {
    // 店铺库存查询与调货
    path: '/stores/store_query_transfer',
    component: () =>
      import(
        '../views/Stores/StoreInventoryTransfer/StoreInventoryTransfer.vue'
      )
  },
  {
    // 业绩与积分查询
    path: '/stores/results_query',
    component: () => import('../views/Stores/ResultsQuery/ResultsQuery.vue')
  },
  {
    // VIP建档与设置
    path: '/stores/store_vip',
    component: () => import('../views/Stores/StoreVIP/StoreVIP.vue')
  },
  {
    // 直营店铺销售查询
    path: '/stores/store_sales_query',
    component: () =>
      import('../views/Stores/StoreSalesQuery/StoreSalesQuery.vue')
  },
  {
    // 直营店铺销售查询
    path: '/stores/K_storeSalesQuery',
    component: () =>
      import('../views/Stores/K_storeSalesQuery/K_storeSalesQuery.vue')
  },
  {
    // 店铺盘点查询
    path: '/stores/store_take_stock_query',
    component: () =>
      import('../views/Stores/StoreInventoryQuery/StoreInventoryQuery.vue')
  },
  {
    // 店铺退货查询
    path: '/stores/store_return_query',
    component: () =>
      import('../views/Stores/StoreReturnQuery/StoreReturnQuery.vue')
  },
  // {
  //   // 公司进退仓查询jin
  //   path: '/stores/company_warehouse_query',
  //   component: () => import('../views/Stores/CompanyWarehouseQuery/CompanyWarehouseQuery.vue')
  // },
  {
    // 公司进退销存查询
    path: '/stores/company_integrated_query',
    component: () =>
      import(
        '../views/Stores/CompanyIntegratedQuery/CompanyIntegratedQuery.vue'
      )
  },
  {
    // 基础信息表
    path: '/stores/store_basic_info',
    component: () => import('../views/Stores/BasicInfo/BasicInfo.vue')
  },
  {
    // 卡别建档
    path: '/stores/card_type',
    component: () => import('../views/Stores/CardType/CardType.vue')
  },

  {
    // label: '主推款信息表',
    path: '/basic_info/mainrecomend_info',
    component: () =>
      import('../views/BasicInfo/F_MainRecInfoTable/MainRecInfoTable.vue')
  },
  {
    // label: '店铺年度计划',
    path: '/management/storeyear_plan',
    component: () =>
      import('../views/Management/F_StoreYearPlan/StoreYearPlan.vue')
  },

  {
    // label: '条码建档',
    path: '/basic_info/barcode_file',
    component: () => import('../views/BasicInfo/F_BarcodeFile/BarcodeFile.vue')
  },
  // {
  //   // 卡别建档
  //   path: '/stores/card_type',
  //   component: () => import('../views/Stores/CardType/CardType.vue')
  // },
  {
    // 销售业绩
    path: '/stores/sales_performance',
    component: () =>
      import('@/views/Stores/K_SalesPerformance/K_SalesPerformance.vue')
  },
  {
    // 积分调整
    path: '/stores/integral_adjustment',
    component: () =>
      import('@/views/Stores/K_IntegralAdjustment/K_IntegralAdjustment.vue')
  },
  {
    // 促销策略建档
    path: '/stores/sales_promotion',
    component: () =>
      import('@/views/Stores/K_SalesPromotion/K_SalesPromotion.vue')
  },
  /* 
    新增的店铺KPI分析
  */

  {
    // 门店运营评估表
    path: '/storekpi/store_assessment',
    component: () =>
      import('@/views/StoreKpi/K_StoreAssessment/K_StoreAssessment.vue')
  },

  {
    // KPI 分析 (还没有移动，暂时放在直营店文件夹里面)
    path: '/storekpi/storekpi_analysis',
    component: () => import('@/views/Stores/K_KPIAnalysis/K_KPLAnalysis.vue')
  },
  {
    // 业绩分析（还没有移动，暂时放在直营店文件夹里面）
    path: '/storekpi/performance_analysis',
    component: () =>
      import('@/views/StoreKpi/K_PerformanceAnalysis/K_PerformanceAnalysis.vue')
  },
  {
    // label: 'KPI一览',
    path: '/storekpi/kpi_browse',
    component: () => import('../views/StoreKpi/F_KpiBrowse/KpiBrowse.vue')
  },
  {
    // 店铺分析
    path: '/storekpi/shop_analysis',
    component: () =>
      import('@/views/StoreKpi/K_shopAnalysis/K_shopAnalysis.vue')
  },
  {
    // 店长看板
    path: '/stores/shop_manager',
    component: () => import('@/views/Stores/K_ShopManager/K_ShopManager.vue')
  },
  {
    // 店铺销售查询
    path: '/stores/K_storeSalesQuery',
    component: () =>
      import('@/views/Stores/K_storeSalesQuery/K_storeSalesQuery.vue')
  },

  /**
   * 系统设置
   */
  {
    // 系统设置
    path: '/management/system_settings',
    component: () =>
      import('../views/Management/SystemSettings/SystemSettings.vue')
  },
  {
    // 权限设置
    path: '/management/permissions',
    component: () => import('../views/Management/Permissions/Permissions.vue')
  },
  {
    // 季度转换
    path: '/management/seasons_change',
    component: () =>
      import('../views/Management/SeasonsChange/SeasonsChange.vue')
  },
  {
    // 操作记录
    path: '/management/operating_record',
    component: () =>
      import('../views/Management/OperatingRecord/OperatingRecord.vue')
  },
  {
    // 修改登录密码
    path: '/management/change_password',
    component: () =>
      import('../views/Management/ChangePassword/ChangePassword.vue')
  },
  {
    // 5UHF_读卡器测试R2000
    path: '/management/card_reader_test',
    component: () =>
      import('../views/Management/CardReaderTest/CardReaderTest.vue')
  },
  {
    // 菜单设置
    path: '/management/menu_settings',
    component: () => import('../views/Management/MenuSettings/MenuSettings.vue')
  },
  {
    // 数据备份
    path: '/management/data_backup',
    component: () => import('../views/Management/DataBackup/DataBackup.vue')
  },
  {
    // RFID条码机测试(ZMIN)
    path: '/management/zmin_test',
    component: () => import('../views/Management/ZMINTest/ZMINTest.vue')
  },
  {
    //错误库存记录
    path: '/management/error_record',
    component: () => import('../views/Management/ErrorRecord/ErrorRecord.vue')
  },

  // 删单
  {
    path: '/delete_document',
    component: () => import('../views/deleteDocument/deleteDocument.vue'),
    children: []
  },

  //仓库 删单
  {
    path: '/warhous_delete',
    component: () => import('../views/WarhousDelete/WarhouseDelete.vue')
  },

  // 首页
  {
    path: '/home',
    component: () => import('../views/Home/Home.vue'),
    children: []
  },

  {
    path: '/404',
    component: () => import('../views/ErrorPages/404.vue')
  },
  {
    path: '/500',
    component: () => import('../views/ErrorPages/500.vue')
  },
  {
    path: '/detail',
    component: () => import('../views/documentDetail.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// 导航守卫
// 使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆
// router.beforeEach((to, from, next) => {
//   if (to.path === '/login') {
//     next()
//   } else {
//     let token = localStorage.getItem('Authorization')

//     if (token === 'null' || token === '') {
//       next('/login')
//     } else {
//       next()
//     }
//   }
// })

export default router
